<?php


namespace app\api\model;

use app\admin\event\SystemLog;
use think\Model;
use think\Db;
class StoreModel extends Model
{
    protected $table = 'jxc_store';

    protected static function init()
    {
        self::observe(SystemLog::class);
    }

    /**
     * @param $data
     * @return \think\Paginator
     * @throws \think\exception\DbException
     */
    public function storeList($data)
    {
        return $this->order('id desc')->page($data['page'], $data['size'])->paginate($data['size']);
    }

    /**
     * @return array
     */
    public function getField()
    {
        return ['name'];
    }

    /**
     * @return array|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getAllStore()
    {
        $list = $this->field('id,name')->select();
        return $list;
    }

    /**
     * @return array|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getAllKeeper()
    {
        $list = DB::name('keeper')->field('id,name')->select();
        return $list;
    }
}
